<?php
/**
 * Created by PhpStorm.
 * User: Dick
 * Date: 2016/3/28
 * Time: 16:46
 */

namespace Method;


class Response
{
    public static function redirect($target)
    {
        $target = self::generateURL($target);
        header('Location: ' . $target);
        exit();
    }

    /**
     * Generate a url, check rewrite setting automatically
     * @param string $target Target URL
     * @return string
     */
    public static function generateURL($target)
    {
        if (strpos($target, '//') !== false) {
            return $target;
        }
        if (file_exists(ROOT_PATH . $target)) {
            return $target;
        }
        return BASE_URL. $target;
    }
}